<?php
/**

 * User:ayou chow
 * Date: 2019-11-30
 * Time: 21:40
 * Info: 公会模型
 */

namespace app\common\model;


use think\Model;

class GuildModel extends Model
{
    protected $connection = 'db_live';

    public function users(){
        return $this->hasMany(UserModel::class,'guild_id','id')->with('profile')->field("id, nick_name, avatar, guild_id");
    }

    public function manager(){
        return $this->hasOne(GuildManagerModel::class,'guild_id','id');
    }

    public function admin(){
        return $this->hasOne(AdminModel::class,'id','admin_id')->field('id,name');
    }
}